<template>
  <el-card shadow="never">
    <e-table
      ref="eTable"
      @getList="handleGetList"
      :tableData="tableData"
      :columns="columns"
      :loading="loading"
      :total="total"
    >
      <el-table-column label="总检查数" slot="check_count" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="handleDetail(scope.row)">{{ scope.row.check_count }}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="已收费数" slot="charge_cost" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="handleDetail(scope.row)">{{ scope.row.charge_cost }}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="未收费数" slot="no_charge_cost" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="handleDetail(scope.row)">{{ scope.row.no_charge_cost }}</el-button>
        </template>
      </el-table-column>
    </e-table>
  </el-card>
</template>

<script>
import { getCheckNumber } from '@/api/reports'

export default {
  data() {
    return {
      total: 1,
      loading: false,
      tableData: [],
      columns: [],
      queryParam: {
        pageSize: 10,
        pageNo: 1,
        dateState: 1
      }
    }
  },
  methods: {
    //columns 动态删减，根据form传递过来的数据
    async handleGetList(param = {}) {
      this.loading = true
      this.columns = [
        {
          label: '检查时间',
          prop: 'chk_time'
        },
        {
          label: '检查科室',
          prop: 'chk_his_dept'
        },
        {
          label: '检查部位',
          prop: 'chk_part'
        },
        {
          label: '病人名称',
          prop: 'patient_name'
        },
        {
          label: '病历号',
          prop: 'med_record_no'
        },
        {
          label: '项目收费',
          prop: 'item_cost'
        },
        {
          label: '开单医生',
          prop: 'bill_his_doctor'
        },
        {
          label: '检查医生',
          prop: 'chk_his_doctor'
        },
        {
          label: '诊断名称',
          prop: 'diag_name'
        },
        {
          label: '检查名称',
          prop: 'chk_name'
        }
      ]
      this.queryParam = Object.assign(this.queryParam, param)
      const res = await getCheckNumber(this.queryParam)
      console.log('res', res)

      if (res && res.data.records.length > 0) {
        const {
          state,
          data: { records, total }
        } = res
        this.tableData = records
        this.total = total
      } else {
        this.tableData = []
        this.total = 1
      }
      this.loading = false
    },
    handleDetail(row) {
      this.$router.push({
        name: 'report11-detail',
        params: { handleRow: row }
      })
    }
  }
}
</script>
